package com.google.superlists.model;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * Represents a list. Parsed from JSON.
 *
 * @author sven
 */
public class SuperList {

  /** Returns a SuperList parsed from json. */
  public static SuperList fromJson(String json) {
    return JsonUtil.fromJson(json, SuperList.class);
  }

  /** ID of this list. (file.id) */
  public String id;

  /** Name of this list. (file.title) */
  public String name;

  /** List of eventIds known to this list. Not stored in the backend. */
  public List<String> eventIds = Lists.newArrayList();

  /** Content of the list. (file.media) */
  public SuperListContent content = new SuperListContent();

  /** Empty constructor required by Gson. */
  public SuperList() {}

  /**
   * Removes any empty items.
   */
  public void removeEmptyItems() {
    content.removeEmptyItems();
  }

  /**
   * Converts this super list to a json blob.
   */
  public String toJson() {
    return JsonUtil.toJson(this);
  }

  @Override
  public String toString() {
    return name + "(" + id + ")" + ": " + content;
  }
}
